package com.atguigu.gamll_sugar.mapper;

import com.atguigu.gamll_sugar.entity.KeywordStats;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author chenlongStart
 * @create 2021-07-07 21:24
 * @desc
 */
public interface KeywordStatsMapper {
    @Select(
            "select keyword," +
                    "   sum(keyword_stats_2021.ct * multiIf( " +
                    "       source='search',10, " +
                    "       source='order',3, " +
                    "       source='cart',2, " +
                    "       source='click',1, " +
                    "       0 " +
                    "   )) ct " +
                    "from keyword_stats_2021 " +
                    "where toYYYYMMDD(stt)=#{date} " +
                    "group by keyword " +
                    "order by sum(keyword_stats_2021.ct) desc " +
                    "limit #{limit} ")
   List<KeywordStats> selectKeywordStats(@Param("date") int date, @Param("limit") int limit);

}
